// 样式-文本设置
import React, { useState } from 'react';
import RichEditor from '../Common/RichEditor';

interface IProps {
	config: any;
	onValuesChange: ( chartType: string, key: string, values: Object, configType: string ) => any;
	form: any;
}

const ContentInput = ( props: IProps ) => {
	const { config, onValuesChange } = props;

	const [ timer, setTimer ] = useState();

	const handleEditorChange = ( data ) => {
		if ( timer ) clearTimeout( timer );
		let newTimer = setTimeout( () => {
			onValuesChange( config.type, config.key, { inputValue: data }, 'mutual' );
		}, 500 );
		setTimer( newTimer );
	};

	return (

		<div style={ { marginBottom: 10 } }>
			<RichEditor value={ config.mutual.inputValue } onchange={ handleEditorChange }></RichEditor>
		</div>

	);
};

export default React.memo( ContentInput );
